package models

import "time"

type Slides struct {
	ID int `gorm:"primary" json:"id"`
	Title string `json:"title"`
	Image string `json:"image"`
	Url string `json:"url"`
	Type string `json:"type"`
	Status string `json:"status"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (s Slides) TableName() string {
	return "slides"
}

func GetAllSlides() ([]*Slides, error) {
	var slides []*Slides
	err := DB.Model(&Slides{}).Where("type=2 AND status=1").Find(&slides).Error

	if err != nil {
		return nil, err
	}
	return slides, nil
}